<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .h {
            color: aquamarine;
        }
    </style>
</head>

<body>
    <div class="box">段落<span>内容<span></div>
    <div class="box">
        <!-- <div class="box">11111</div> -->
        段落内容
    </div>
    <div class="box">段落内容</div>
</body>
<script>
    var box = document.getElementsByClassName('box')[0];
    var box1 = document.getElementsByClassName('box')[1];
    // console.log(box);

    // 获取对象的文本 获取标签里的所有内容(不管是啥)
    console.log(box1.innerHTML);

    //给节点里的内容赋值innerHTML
    box1.innerHTML='<h1>张三李四往往<h1>';
    // box1.innerHTML = '<h1 class="h">张三李四往往<h1>';

    //仅设置文本innerText
    var box2 = document.getElementsByClassName('box')[2];
    console.log(box2.innerText);
    box2.innerText = '<h1 class="h">张三李四往往<h1>';
</script>

</html>